package cn.zjq.unilityclass.kehouzuoye.two;

import java.util.Scanner;

public class StrDemo {

    public static void main(String[] args) {
        boolean result = true;
        int count = 0;
        Scanner input = new Scanner(System.in);
        System.out.print("请输入一串字符串：");
        String word = input.next();
        System.out.print("请输入您要查找的字符：");
        String check = input.next();
        do {
            if (word.contains(check)) {
                count++;
                word = word.substring(word.indexOf(check)+check.length());
            } else {
                result = false;
            }
        }
        while (result);
        System.out.println("\"" + check + "\"出现的次数为：" + count);
    }
}
